<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class ArticleResource extends JsonResource
{

    public function toArray($request): array
    {

        return [
            'id' => $this->id ?? 0,
            'title' => $this->title ?? '',
            'content' => $this->content ?? '',
            'created_at' => isset($this->created_at) ? $this->created_at->toDateTimeString() : ''
        ];
    }
}
